package cn.xorange.commons.file.configuration;

import io.minio.MinioClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Minio 配置信息
 *
 * @author ruoiy
 */
@Component
@ConditionalOnProperty(name = "oss.minio.enable",havingValue = "true")
public class MinioConfig {

    @Resource
    FileConfig fileConfig;

    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(fileConfig.minioProperties().getDomain())
                .credentials(fileConfig.minioProperties().getAccessKey(), fileConfig.minioProperties().getSecretKey())
                .build();
    }
}
